package com.bcntouch.touch2act.Suggest;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.bcntouch.touch2act.R;
import com.bcntouch.touch2act.Constants.Constants;

public class SuggestionTypesActivity extends Activity {
	
	public final static String EXTRA_SUGGESTION_TYPE = Constants.AUTHORITY + ".SUGGESTION_TYPE";
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_suggestion_types);
//        getActionBar().setDisplayHomeAsUpEnabled(true);
        
        final String[] suggestionTypesArray = {
    			getString(R.string.educacio),
    			getString(R.string.seguretat),
    			getString(R.string.cultura),
    			getString(R.string.turisme),
    			getString(R.string.dinamitzacio_economica),
    			getString(R.string.mobilitat),
    			getString(R.string.qualitat_ambiental),
    			getString(R.string.accessibilitat),
    			getString(R.string.austeritat)
    			};
        
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, suggestionTypesArray);
        ListView listView = (ListView) findViewById(R.id.suggestion_types_list_view);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				onSuggestionTypeSelected(suggestionTypesArray[position]);
			}
		});
    }

//    @Override
//    public boolean onCreateOptionsMenu(Menu menu) {
//        getMenuInflater().inflate(R.menu.activity_new_suggestion, menu);
//        return true;
//    }

    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                NavUtils.navigateUpFromSameTask(this);
                return true;
        }
        return super.onOptionsItemSelected(item);
    }
    
    public void onSuggestionTypeSelected(String suggestionType) {
    	Intent intent = new Intent(this, NewSuggestionActivity.class);
    	intent.putExtra(EXTRA_SUGGESTION_TYPE, suggestionType);
    	startActivity(intent);
    }

}
